package com.xiangha.springboot.service.impl;

import com.xiangha.springboot.pojo.Checkins;
import com.xiangha.springboot.dao.ICheckinsDao;
import com.xiangha.springboot.service.ICheckinsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 签到表 服务实现类
 * </p>
 *
 * @author itlong
 * @since 2025-09-19 03:40:35
 */
@Service
public class CheckinsServiceImpl extends ServiceImpl<ICheckinsDao, Checkins> implements ICheckinsService {
@Autowired
ICheckinsDao checkinsDao;
    @Override
    public List<Checkins> cancelByCheckinIdCheckins(Integer userId) {
        return checkinsDao.cancelByCheckinIdCheckins(userId);
    }

    @Override
    public boolean hasCheckedInToday(Integer userId) {
        return this.lambdaQuery()
                .eq(Checkins::getUserId, userId)
                .apply("DATE(checkin_date) = CURDATE()")
                .count() > 0;
    }
}
